package com.lxh.lxhcrm.model.pojos;

import javax.persistence.*;
import java.util.List;
import java.util.Objects;

/**
 * 职位表
 */
@Entity
public class Position {
    private int positionId;
    private String positionName;
    /*职位对功能 多对多*/
    private List<Function> functions;
@ManyToMany
@JoinTable(name="post_fun",
        joinColumns = {
                @JoinColumn(name="position_id")
        },inverseJoinColumns = {
        @JoinColumn(name="function_id")
})
    public List<Function> getFunctions() {
        return functions;
    }

    public void setFunctions(List<Function> functions) {
        this.functions = functions;
    }

    /*职位对员工 一对多*/
    private List<Emp> poEmp;
    @OneToMany(mappedBy = "pos")
    public List<Emp> getPoEmp() {
        return poEmp;
    }
    public void setPoEmp(List<Emp> poEmp) {
        this.poEmp = poEmp;
    }

    @Id
    @Column(name = "position_id", nullable = false)
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    public int getPositionId() {
        return positionId;
    }

    public void setPositionId(int positionId) {
        this.positionId = positionId;
    }

    @Basic
    @Column(name = "position_name", nullable = true, length = 20)
    public String getPositionName() {
        return positionName;
    }

    public void setPositionName(String positionName) {
        this.positionName = positionName;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Position position1 = (Position) o;
        return positionId == position1.positionId &&
                Objects.equals(positionName, position1.positionName);
    }

    @Override
    public int hashCode() {
        return Objects.hash(positionId, positionName);
    }
}
